package qiniu

import (
	"github.com/qiniu/api/conf"
	"github.com/qiniu/api/io"
	"github.com/qiniu/api/rs"
)

func init() {
	conf.ACCESS_KEY = "f1nHN2EMEa1q7FH3oiA30v_2GdcsM_1hEQtVxkxQ"
	conf.SECRET_KEY = "IBkY9VAO_DJQna-IHT4Gk19XQ0FvPW_Mu_WlTm4H"
}

const scope = "appnodebyyang"

// 上传文件
func Put(filename string) (name string, err error) {
	var ret io.PutRet
	var extra = &io.PutExtra{}

	putPolicy := rs.PutPolicy{
		Scope: scope,
	}

	uptoken := putPolicy.Token(nil)

	err = io.PutFileWithoutKey(nil, &ret, uptoken, "yy", extra)

	if err != nil {
		return "", err
	}

	return ret.Key, nil

}

// delete file
func Delete(filename string) (err error) {
	client := rs.New(nil)
	return client.Delete(nil, scope, filename)

}
